xlv.obj.valueMap={
	extend:function(){
	},
	implement:function(){
		this.implement('xlv.imp.mvc');
	},
	create:function(tag){
		var div=document.createElement((tag||'div'));
		div.setAttribute('xlvobject','xlv.obj.valueMap');
		return div;					 
	},
	properties:{
		dmName:null,
		dmPath:null,
		lookupdmName:null,
		lookupdmPath:null,
		lookupdmTextPath:null
	},
	method:{
		construct:function(){
		},
		initial:function(){
		},
		getTagElement:function(){
			return this;
		},
		_isModel:function(dm){
			return this.$P.dmName==dm.getName();
		},
		_isLookupModel:function(dm){
			return this.$P.lookupdmName==dm.getName();
		},
		mvc_isModel:function(dm){
			return (this._isModel(dm)||this._isLookupModel(dm));
		},
		mvc_addListener:function(){
			var dm;
			if(dm=this.mvc_getModel(this.$P.dmName))dm.addListener(this);
			if(dm=this.mvc_getModel(this.$P.lookupdmName))dm.addListener(this);
		},
		mvc_removeListener:function(){
			var dm;
			if(dm=this.mvc_getModel(this.$P.dmName))dm.removeListener(this);
			if(dm=this.mvc_getModel(this.$P.lookupdmName))dm.removeListener(this);
		},
		mvc_valueFromModel:function(dm){
			if(this._isModel(dm)) return dm.getValue(this.$P.dmPath);
			return null;
		},
		mvc_valueToModel:function(value,dm){
			//if(this._isModel(dm)) dm.setValue(value,this.$P.dmPath);
		},
		mvc_beforeModelChanged:function(dm,notify,memo){
		},
		mvc_modelChanged:function(dm,notify,memo){
			switch(notify){
				case 'nodeChanged':
					if(memo.type=='update'){
						if(this._isModel(dm))this.mvc_valueToView(this.mvc_valueFromModel(dm));
					}
					break;
				case 'cursorMove' :
					if(this._isModel(dm)) this.mvc_valueToView(this.mvc_valueFromModel(dm));
					break;
			}
		},
		mvc_afterModelChanged:function(dm,notify,memo){
			if(!this.mvc_isModel(dm))return;
			switch(notify){
				case 'setChanged' :
					if(this.mvc_isModel(dm)) this.mvc_valueToView(this.mvc_valueFromModel(dm));
					break;
				case 'rowChanged':
					if(this.mvc_isModel(dm))this.mvc_valueToView(this.mvc_valueFromModel(dm));		
					break;
			}
			this.mvc_enableControl(dm);
		},
		mvc_enableControl:function(dm){
		},
		mvc_valueToView:function(value){
			var dm=this.mvc_getModel(this.$P.lookupdmName);
			if(dm){
				var node=dm.getNode('', this.$P.lookupdmPath+'="'+value+'"');
				if(node){
					var text=dm.xml_selectSingleNode(this.$P.lookupdmTextPath,node);
					xlv.util.setElementValue(this,dm.xml_getNodeValue(text));
				}
			}
		},
		mvc_valueFromView:function(){
			return xlv.util.getElementValue(this);
		}
	}
};
